import axios from 'axios';
import querystring from 'querystring';
// import { ApiHost, UserAgent } from '../config/variable';
import { getParams, getHeader } from '../utils/requestUtils';

const request = async (url, params?) => {
  const _params = getParams(params);
  const searchUrl = `${url}?` + querystring.stringify(_params);
  const headers = getHeader(searchUrl, 'GET', 'application/json', _params);
  // console.log(searchUrl)
  // console.log(headers)
  // const headers = getHeader(searchUrl, 'GET', 'application/x-www-form-urlencoded; charset=UTF-8', _params);
  return axios.get(searchUrl, {
    headers
  });
};

export const sendSmsCode = (params) => {
  const url = 'https://qapi.huolala.cn/send_sms_code';
  return request(url, params);
};


export const calcPrice = (params) => {
  const url = 'https://qapi.huolala.cn/price_index_calculate_v2';
  return request(url, params);
};

export const getCityInfo = (params) => {
  const url = 'https://qapi.huolala.cn/city_info';
  return request(url, params);
};

export const getCityList = () => {
  const url = 'https://qapi.huolala.cn/city_list';
  return request(url);
};

export const getServiceList = (params) => {
  const url = 'https://qapi.huolala.cn/get_service_list';
  return request(url, params);
};


// https://www.ljczero.top/article/2022/9/5/144.html
// odjP50PsSsghT4txthtnGeyAL-K4